﻿@model Xms.Web.Models.BasicSettingModel

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            <a data-toggle="collapse"
               href="#collapseTwo">
                <strong>@app.PrivilegeTree?.LastOrDefault().DisplayName</strong>
            </a>
        </h3>
    </div>
    <div class="panel-body">
        <form id="editform" class="form-horizontal" data-jsonajax="true" data-istip="true" action="/@(app.OrganizationUniqueName)/api/settings/basic" method="post">
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="SystemName">系统名称</label>
                <div class="col-sm-10">
                    @Html.TextBoxFor(x => x.SystemName, new { @class = "form-control required" })
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="Announcement">公告</label>
                <div class="col-sm-10">
                    @Html.TextAreaFor(x => x.Announcement, 10, 0, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="QrCode">公众号二维码</label>
                <div class="col-sm-10">
                    <img id="imgQrCode" width="100" height="100" src="@Model.QRCode"/>
                    <input type="file" accept=".png,.jpg,.gif" name="imgQrCodeFile" id="imgQrCodeFile" class="form-control hidden" onchange="UploadImg();" />
                    <a class="btn btn-default btn-upload" onclick="$('#imgQrCodeFile').click();"><i class="glyphicon glyphicon-open"></i><span>上传图片</span></a>
                    @Html.HiddenFor(x => x.QRCode)
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="CompanyProfile">公司简介</label>
                <div class="col-sm-10">
                    @Html.TextAreaFor(x => x.CompanyProfile, 10, 0, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="ContactPhone">联系电话</label>
                <div class="col-sm-10">
                    @Html.TextBoxFor(x => x.ContactPhone, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="ContactAddress">联系地址</label>
                <div class="col-sm-10">
                    @Html.TextBoxFor(x => x.ContactAddress, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" for="PrincipalMailbox">校长信箱</label>
                <div class="col-sm-10">
                    @Html.TextBoxFor(x => x.PrincipalMailbox, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group col-sm-12 text-center" id="form-buttons">
                <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-saved"></span> @app.T["save"]</button>
                <button type="reset" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> @app.T["reset"]</button>
            </div>
        </form>
    </div>
</div>
@section Scripts {
    <script src="/content/js/jquery.form.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script src="/content/js/jquery-validate/jquery.validate.min.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script src="/content/js/jquery-validate/localization/messages_zh.min.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script>
        $(function () {
            //表单验证
            var $form = $("#editform");
            Xms.Web.Form($form, function (response) {
                console.log(response);
                //Xms.Web.Toast(response.Content, response.IsSuccess);
            });
            $(".xmscheckbox").xmsCheckbox();
            Xms.Web.SelectedValue($('#loglevel'), $('#loglevel').data('value'));
        });

        function UploadImg() {
            var fordata = new FormData();
            fordata.append('myfiles', $('#imgQrCodeFile')[0].files[0]);
            $.ajax({
                url: '/@(app.OrganizationUniqueName)/api/settings/PostQrCodeImg',
                type: 'post',
                processData: false,
                contentType: false,
                data: fordata,
                success: function (result) {
                    $("#imgQrCode").attr("src", result.Extra);
                    $("#QRCode").val(result.Extra);
                }
            })
        }
    </script>
}